/**
 * Created by WYH on 17/4/22.
 */
angular.module('tribalc').controller(
    'LocksManagerController',
    ['$scope','Api', 'LockModel','Alert', function ($scope, Api, LockModel,Alert) {

        $scope.isCanEdit = true;

        $scope.hideRentButton = false;
        $scope.hideSearch = true;
        getLockList();

        $scope.showLockFillIn = false;
        
        $scope.clickAdd = showAddLock;

        $scope.clickDelete = showDeleteLock;

        function showDeleteLock() {
            if (!$scope.selectedLock) {
                Alert.alertBox('未选中任何设备');
            } else {
                $scope.showLockDelete = true;
            }
        }
        
        function showAddLock() {
            $scope.modifyLock = null;
            $scope.showLockFillIn = true;
        }

        function getLockList() {

            Api.getAuthLockList(function (result) {
                $scope.lockList = LockModel.setupLocks(result.data);
                // $scope.lockList={};
                // console.log($scope.lockList);
                

            });
            
        }

    }]
);